package pers.wensheng.patterns.structural_pattern.combination_pattern.transparent_combination_pattern.entity;

/**
 * 菜单项类
 * 叶子节点
 */
public class MenuItem extends MenuComponent {

    public MenuItem(String name,int level){
        this.name = name;
        this.level = level;
    }

    /**
     * 打印菜单名称的方法（包含子菜单和子菜单项）
     */
    @Override
    public void print() {
        for (int i = 0; i < level; i++) {
            System.out.print("-");
        }
        //打印菜单项
        System.out.println(name);
    }
}
